﻿using Pub.DBService;
using System;
using System.Collections.Generic;
using System.Data;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DBTest
{
    /// <summary>
    /// 测试数据库相关类 主要测试SQL lite
    /// </summary>
    class Program
    {
        static void Main(string[] args)
        {
        
            string strPath = System.Environment.CurrentDirectory + "\\testDB.db";//获取当前路径
            clsDBService objService = new clsDBService(strPath);
            if (!File.Exists(strPath))
            {
                objService.m_mthCreateDB(strPath);
               // objService.m_mthChagePassword();
                long l = 0;
                objService.ExecParamSQL(@"create table bse_UserInfo(
UserLOCALID  integer primary key,
UserCellPhone varchar,
UserEmail varchar,
UserName varchar,
UserNicheng varchar,--昵称
UserSex int ,--姓名别0男 1女 
UserBirth DATE,--日期
UserPwd varchar --密码
)", ref l);
            }
            string strInsertSql = @"insert into bse_UserInfo(UserCellPhone,
UserEmail,
UserName,
UserNicheng,
UserSex,
UserBirth,
UserPwd) values(?,?,?,?,?,?,?)";
            IDataParameter[] pas= null;
            objService.CreateParameters(7,out pas);
            pas[0].Value = "15200001111";
            pas[1].Value = "163dd@qq.com";
            pas[2].Value = "南慕容";
            pas[3].Value = "慕容复";
            pas[4].Value = 1;
            pas[5].Value = DBNull.Value;
            pas[6].Value = "paaword";

            long aa = 0;
            long len = objService.ExecParamSQL(strInsertSql, ref aa,pas);
            Console.WriteLine("创建完毕 OK。。。。");
            string strSQL = "select * from bse_UserInfo";
            DataTable dt=null;
            objService.GetTableWithParams(strSQL, ref dt);
            Console.WriteLine("查询数量："+dt.Rows.Count);
            Console.ReadKey();
        }
    }
}
